package com.mcy.springbatch.writer;

import com.mcy.springbatch.entity.SysUser;
import org.springframework.batch.item.support.CompositeItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Arrays;

/**
 * 利用CompositeItemWriter把数据到多个文件
 * @author : Create By mcy
 * @date : 2019/8/25 16:27:24
 */
@Component
public class SysUserCompositeItemWriter extends CompositeItemWriter<SysUser> {

    @Autowired
    SysUserFlatFileItemWriter sysUserFlatFileItemWriter;

    @Autowired
    SysUserStaxEventItemWriter sysUserStaxEventItemWriter;


    @PostConstruct
    public void init(){
        setDelegates(Arrays.asList(sysUserFlatFileItemWriter,sysUserStaxEventItemWriter));
    }
}
